/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.ucase.casemain.controller;

import com.icinfo.cloud.provider.punish.ucase.casemain.service.ICaseMainInfoStatusChangeRecordService;
import com.icinfo.cloud.provider.punish.ucase.investigateevidence.dto.CaseOperateUpdateDto;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 描述: 案件暂停恢复记录表 case_main_info_status_change_record 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年05月23日
 */
@RestController
@RefreshScope
@Slf4j
@RequestMapping("/punish/ucase/case/main/change")
public class CaseMainInfoStatusChangeRecordController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(CaseMainInfoStatusChangeRecordController.class);

    @Autowired
    private ICaseMainInfoStatusChangeRecordService caseMainInfoStatusChangeRecordService;

    /**
     * 【V2.0.0】描述：案件操作
     *
     * @param saveDto 保存dto
     * @return {@link Result <String> }
     * @author shishengyao
     * @date 2022/05/12
     */
    @PostMapping(value = "/saveCaseChangeOperate")
    public Result<String> saveCaseChangeOperate(@RequestBody @Validated CaseOperateUpdateDto saveDto) {
        int count = caseMainInfoStatusChangeRecordService.saveCaseChangeOperate(saveDto);
        if (count <= 0) {
            return Result.success("案件操作成功");
        }
        return Result.error("案件操作失败！");
    }

    /**
     * 案件恢复
     *
     * @param saveDto 保存dto
     * @return {@link Result<String> }
     * @author shishengyao
     * @date 2022/05/30
     */
    @PostMapping("/recoverCase")
    public Result<String> recoverCase(@RequestBody @Validated CaseOperateUpdateDto saveDto ){
        if (caseMainInfoStatusChangeRecordService.recoverCase(saveDto.getCaseId()) < 1) {
            return Result.error("案件恢复失败");
        }
        return Result.success("案件恢复成功");
    }


}
